<template>
  <div id="MusicList" style="width: 100%;height: 100%;">
    <update-info class="updateBox updateInfo" :musicArtInfo="musicArtInfo"/>
    <el-container>
      <el-main style="height: 100%;padding: 0;">
        <el-table class="musicArtList"
          :data="musicArtTable"
          stripe
          style="width: 100%;height: 100vh;background-color: var(--theme-bgColor-aside-nav)"
          >
          <el-table-column prop="musicArtId" label="歌手ID" width="70px">
          </el-table-column>
          <el-table-column prop="musicArt" label="歌手名" width="100px">
          </el-table-column>
          <el-table-column prop="artEnName" label="英文名" width="100px">
          </el-table-column>
          <el-table-column prop="artNickName" label="别名" width="100px">
          </el-table-column>
          <el-table-column prop="artCountry" label="国籍" width="100px">
          </el-table-column>
          <el-table-column prop="artBirthday" label="生日" width="100px">
          </el-table-column>
          <el-table-column prop="artCompany" label="现公司" width="100px">
          </el-table-column>
          <el-table-column prop="artMainMusic" label="主要作品" width="200px">
          </el-table-column>
          <el-table-column prop="artProfession" label="职业" width="100px">
          </el-table-column>
          <el-table-column prop="artBasicInfo" label="歌手简介">
          </el-table-column>
          <el-table-column
            fixed="right"
            label="操作">
            <template slot-scope="scope">
              <el-button @click="updateMusicArt(scope.row)" type="text" size="small">修改</el-button>
              <el-button @click="deleteMusicArt_(scope.row)" type="text" size="small">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-main>
    </el-container>
  </div>
</template>

<script>
  import api from "../../model/api";
  import updateInfo from "./updateInfo";
  import $ from "jquery";

  export default {
    name: "MusicList",
    data() {
      return {
        musicArtTable:[],
        musicArtInfo:{},
      }
    },
    components:{
      updateInfo,
    },
    created() {
      this.getMusicsList()
    },
    methods:{
      getMusicsList(){
        api.getMusicArt().then(res => {
          this.musicArtTable = res.data
        })
      },
      updateMusicArt(val){
        this.musicArtInfo = val
        $('.updateInfo').css('display','block')
        console.log(val)
      },
      async deleteMusicArt_(val){
        this.$confirm('是否删除该歌手信息?（此操作会导致歌手信息缺失）', '谨慎操作', {confirmButtonText: '确定',cancelButtonText: '取消', type: 'warning'}).then(()=>{
          this.deleteMusicArt(val.musicArtId)
        }).catch(()=>{
        })
      },
      deleteMusicArt(musicArtId){
        console.log(musicArtId)
      }

    }
  }
</script>

<style lang="less" scoped>

  /deep/ .musicArtList{
    .cell{max-height: 94px !important;overflow: auto !important;}
  }

</style>
